﻿using Management.HttpApi.Host.Helpers;
using Microsoft.AspNetCore.Mvc;

namespace Management.HttpApi.Host.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class AuthController : ControllerBase
    {
        private readonly ILogger<AuthController> _logger;

        public AuthController(ILogger<AuthController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public IActionResult GetToken(string account, string password)
        {
            //var lLoginResult = _userService.GetUserByLogin(account, password);

            // if (lLoginResult != null)
            // {
            //     var lUserPro = _userService.GetUserProfileById(lLoginResult.Id);
            //
            //     return Ok(new
            //     {
            //         access_token = TokenHelper.GenerateToken(lUserPro),
            //     });
            // }
            if (account == "admin" && password == "admin")
            {
                var lz = TokenHelper.GenerateToken();
                return Ok(new
                {
                    access_token = lz
                });
            }
            else
            {
                return Ok(new
                {
                    error = "账号或密码错误"
                });
            }
        }
    }
}
